<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <script>
    
    // const getQueryStringArgs = () => {
    //   // 删除开头的问号
    //   const qs = (location.search.length > 0 ? location.search.substring(1) : '')
    //   const args = {}

    //   for(let item of qs.split('&').map(kv => kv.split('='))) {
    //     const name = decodeURIComponent(item[0])
    //     const value = decodeURIComponent(item[1])
    //     if(name.length) {
    //       args[name] = value
    //     }
    //   }
    //   return args
    // }

    // const args = getQueryStringArgs()
    // console.log(args)

    let searchParams = new URLSearchParams(location.search)
    
    if(searchParams.has('id')) {
      console.log(searchParams.get('id'))
    }

    for (let item of searchParams) {
      console.log(item)
    }
  </script>
</body>
</html>